<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    //
    class Computer{
      //属性
      brand;
      price;
      //实例对象添加 run 方法
      run = function(){
        console.log('运行2');
      }

      //方法  执行时机: 当使用 new 实例化的对象的时候, 会『自动』执行该方法
      //作用: 初始化实例对象
      constructor(brand, price){
        this.brand = brand;
        this.price = price;
      }

      run(){
        console.log('运行1');
      }
    }

    //继承
    class Laptop extends Computer{
      //内存
      memory;
      //型号
      version;
      //构造方法
      constructor(brand, price, memory, version) {
        // 在构造方法中使用的一个函数. 
        // super 调用的是父类的构造方法
        super(brand, price);
        this.memory = memory;
        this.version = version;
      }

      run() {
        console.log('运行3');
      }
    }

    //实例化
    // let thinkpad = new Computer('联想', 4399);
    // thinkpad.run();

    let xiaomi = new Laptop('小米', 2999, '16G', 'V2.5');

    console.log(xiaomi);

    xiaomi.run();



    //React.Component
    class Component{}
    let React = {};

    React.Component = Component;

    class A extends React.Component{}

    let a = new A();
    console.log(a);
  </script>
</body>
</html>